package com.danskin.wechat.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.danskin.wechat.dao.VipActivityDao;
import com.danskin.wechat.entity.ActivityApply;
import com.danskin.wechat.entity.ActivityApplyConfig;
import com.danskin.wechat.entity.ActivityMiddle;
import com.danskin.wechat.entity.CustActivityApply;
import com.danskin.wechat.entity.VipActivity;
import com.danskin.wechat.entity.VipOption;
import com.danskin.wechat.entity.VipVote;
import com.danskin.wechat.entity.example.VipActivityExample;
import com.danskin.wechat.entity.example.VipActivityExample.Criteria;
import com.danskin.wechat.service.VipActivityService;
import com.danskin.wechat.util.Page;
@Service
public class VipActivityServiceImpl implements VipActivityService{
	@Autowired
	private VipActivityDao vipActivityDao;

	@Override
	public List<VipActivity> findVipActivityList(Page page) {
		return vipActivityDao.listPageVipActivityList(page);
	}



	@Override
	public void insertVipActivity(VipActivity vipActivity) {
		vipActivityDao.insertVipActivity(vipActivity);
	}

	@Override
	public void updateVipActivity(VipActivity vipActivity) {
		vipActivityDao.updateVipActivity(vipActivity);
	}

	@Override
	public VipActivity findVipActivitybyId(String id) {
		// TODO Auto-generated method stub
		return vipActivityDao.findVipActivitybyId(id);
	}

	@Override
	public int saveVipVote(VipVote vipVote) {
		// TODO Auto-generated method stub
		return vipActivityDao.saveVipVote(vipVote);
	}

	@Override
	public void saveVipOption(VipOption vipOption) {
		// TODO Auto-generated method stub
		vipActivityDao.saveVipOption(vipOption);
	}

	@Override
	public void saveEnrrollVipActivity(VipActivity vipActivity) {
		// TODO Auto-generated method stub
		vipActivityDao.insertVipActivity(vipActivity);
	}

	@Override
	public List<ActivityApplyConfig> findActivityApplyConfig() {
		// TODO Auto-generated method stub
		return vipActivityDao.findActivityApplyConfig();
	}

	@Override
	public void insertActivityApply(ActivityApply activityApply) {
		// TODO Auto-generated method stub
		vipActivityDao.insertActivityApply(activityApply);
	}

	@Override
	public void deleteActivityApply(String activityId) {
		// TODO Auto-generated method stub
		vipActivityDao.deleteActivityApply(activityId);
	}

	@Override
	public void insertActivityMiddle(ActivityMiddle activityMiddle) {
		// TODO Auto-generated method stub
		vipActivityDao.insertActivityMiddle(activityMiddle);
	}

	@Override
	public List<CustActivityApply> queryCostActivityApply(CustActivityApply custActivityApply) {
		// TODO Auto-generated method stub
		return vipActivityDao.queryCostActivityApply(custActivityApply);
	}

	@Override
	public List<ActivityApply> findActivityApply(String activityId) {
		// TODO Auto-generated method stub
		return vipActivityDao.findActivityApply(activityId);
	}

	@Override
	public List<CustActivityApply> queryActivityMiddleColumn(String activityId, String column) {
		// TODO Auto-generated method stub
		return vipActivityDao.queryActivityMiddleColumn(activityId,column);
	}

	@Override
	public ActivityApply queryActivityApply() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void deleteActivityMiddle(String activityId) {
		// TODO Auto-generated method stub
		vipActivityDao.deleteActivityMiddle(activityId);
	}

	@Override
	public List<ActivityMiddle> findActivityMiddleList(Page page) {
		// TODO Auto-generated method stub
		return vipActivityDao.listPageActivityMiddle(page);
	}

	@Override
	public void deleteActivityMiddleTJ(String id) {
		// TODO Auto-generated method stub
		vipActivityDao.deleteActivityMiddleTJ(id);
	}

	public List<ActivityMiddle> getActivityMiddleExecl(String activityId, String title) {
		// TODO Auto-generated method stub
		return vipActivityDao.getActivityMiddleExecl(activityId,title);
	}

	@Override
	public List<VipActivity> findVipActivityListAPI(Page page) {
		// TODO Auto-generated method stub
		return vipActivityDao.listPageFindVipActivityListAPI(page);
	}

	@Override
	public List<VipActivity> queryVipActivityList(Page page) {
		// TODO Auto-generated method stub
		return vipActivityDao.listPageQueryVipActivityList(page);
	}

	@Override
	public VipActivity queryVipActivityDetails(String id,String appId,String openId) {
		// TODO Auto-generated method stub
		return vipActivityDao.queryVipActivityDetails(id,appId,openId);
	}

	@Override
	public List<VipActivity> findGoOverVipActivity(Page page) {
		// TODO Auto-generated method stub
		SimpleDateFormat fmt=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Map<String, Object> map = page.getMap();
		String endTime = fmt.format(new Date());
		map.put("endTime", endTime);
		return vipActivityDao.listPageFindGoOverVipActivity(page);
	}

	@Override
	public List<VipActivity> findVipActivityAll(Page page) {
		// TODO Auto-generated method stub
		return vipActivityDao.listPageFindVipActivityAll(page);
	}

	@Override
	public List<VipActivity> queryVipActivityCount(List<Integer> listId) {
		// TODO Auto-generated method stub
		return vipActivityDao.queryVipActivityCount(listId);
	}

	@Override
	public List<VipActivity> fintVipActivityAll() {
		// TODO Auto-generated method stub
		return vipActivityDao.fintVipActivityAll();
	}

	@Override
	public void updateVipActivityState(List<Integer> idList) {
		// TODO Auto-generated method stub
		vipActivityDao.updateVipActivityState(idList);
	}
	/**
	 * 新增凝聚日活动
	 */
	@Override
	public int saveNingActivity(VipActivity vipActivity) {
		int i = vipActivityDao.insertSelective(vipActivity);
		return i;
	}
	/**
	 * 删除活动
	 */
	@Override
	public int deleteVipActivity(Integer id) {
		int i = vipActivityDao.deleteByPrimaryKey(id);
		return i;
	}



	@Override
	public int updateApplyActivity(VipActivity vipActivity) {
		int i = vipActivityDao.updateByPrimaryKeySelective(vipActivity);
		return i;
	}



	@Override
	public VipActivity selectVipActivityByPrimaryKey(Integer id) {
		VipActivity vipActivity = vipActivityDao.selectByPrimaryKey(id);
		return vipActivity;
	}




}
